package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysAppConfigGetPageReq struct {
	dto.Pagination `search:"-"`
}

type SysAppConfigOrder struct {
	IdOrder        int    `search:"type:order;column:id;table:sys_colleges" form:"id_sort"`
	IsTopOrder     int    `search:"type:order;column:is_top;table:sys_colleges" form:"is_top_sort"`
	CreatedAtOrder string `search:"type:order;column:created_at;table:sys_colleges" form:"created_at_sort"`
	UpdatedAtOrder string `search:"type:order;column:updated_at;table:sys_colleges" form:"updated_at_sort"`
}

func (m *SysAppConfigGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysAppConfigInsertReq struct {
	Id               int    `json:"id" comment:"主键ID"`
	Name             string `json:"name" comment:"名称" vd:"@:len($)>0; msg:'名称不能为空'"`
	IconUrl          string `json:"icon_url" comment:"图片链接地址" vd:"@:len($)>0; msg:'图标地址不能为空'"`
	LinkUrl          string `json:"link_url" comment:"链接地址"`
	LinkUrlIsOutSide int    `json:"link_url_is_out_side"comment:"是否外部链接 1为外部"`
	IsShow           int    `json:"is_show" comment:"是否展示"`
	common.ControlBy
	common.ModelTime
}

func (s *SysAppConfigInsertReq) Generate(model *models.SysAppConfig) {
	//model.CourseId = s.CourseId
	model.Name = s.Name
	model.LinkUrl = s.LinkUrl
	model.IconUrl = s.IconUrl
	if s.LinkUrlIsOutSide != 1 {
		model.LinkUrlIsOutSide = 2
	} else {
		model.LinkUrlIsOutSide = s.LinkUrlIsOutSide
	}

	model.IsShow = s.IsShow
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
}

func (s *SysAppConfigInsertReq) GetId() interface{} {
	return s.Id
}

type SysAppConfigUpdateReq struct {
	Id               int    `json:"id" comment:"主键ID" vd:"$>0; msg:'需要更新的ID不能为空'"`
	Name             string `json:"name" comment:"名称" vd:"@:len($)>0; msg:'名称不能为空'"`
	IconUrl          string `json:"icon_url" comment:"图片链接地址" vd:"@:len($)>0; msg:'图标地址不能为空'"`
	LinkUrl          string `json:"link_url" comment:"链接地址"`
	LinkUrlIsOutSide int    `json:"link_url_is_out_side" comment:"是否外部链接 1为外部"`
	IsShow           int    `json:"is_show" comment:"是否展示"`
	common.ControlBy
}

func (s *SysAppConfigUpdateReq) Generate(model *models.SysAppConfig) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.IconUrl = s.IconUrl
	model.LinkUrl = s.LinkUrl
	if s.LinkUrlIsOutSide != 1 {
		model.LinkUrlIsOutSide = 2
	} else {
		model.LinkUrlIsOutSide = s.LinkUrlIsOutSide
	}
	model.IsShow = s.IsShow
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

func (s *SysAppConfigUpdateReq) GetId() interface{} {
	return s.Id
}

type SysAppConfigById struct {
	dto.ObjectById
	common.ControlBy
}

type SysAppConfigUpdateTopStatusReq struct {
	Id    int `json:"id" comment:"更新ID" vd:"$>0; msg:'更新ID不能为空'"`
	IsTop int `json:"is_top" comment:"置顶状态"`
	common.ControlBy
}

func (s *SysAppConfigUpdateTopStatusReq) Generate(model *models.SysAppConfig) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

type SysAppConfigSearchReq struct {
	Name string `form:"name" search:"type:contains;column:name;table:sys_class" comment:"根据班主任名称搜索关键字"`
}

func (m *SysAppConfigSearchReq) GetNeedSearch() interface{} {
	return *m
}
